package com.zhentao.controller;

import com.zhentao.model.dto.order.OrderStatisticsDto;
import com.zhentao.model.entity.order.OrderInfo;
import com.zhentao.model.vo.common.Result;
import com.zhentao.model.vo.common.ResultCodeEnum;
import com.zhentao.model.vo.order.OrderInfoVo;
import com.zhentao.model.vo.order.OrderStatisticsVo;
import com.zhentao.service.OrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author : mgh
 * @date : 2024-08-20 10:07
 * @effect : 当前类的作用是
 * @projectTeam :
 */
@RestController
@RequestMapping("/admin/order/orderInfo")
public class OrderInfoController {
    @Autowired
    private OrderInfoService orderInfoService;

    /**
     * 订单统计--------柱状图
     * @param orderStatisticsDto
     * @return
     */
    @GetMapping("/getOrderStatisticsData")
    public Result getOrderStatisticsData(OrderStatisticsDto orderStatisticsDto){
        OrderStatisticsVo orderStatisticsVo = orderInfoService.getOrderStatisticsData(orderStatisticsDto);
        return Result.build(orderStatisticsVo , ResultCodeEnum.SUCCESS) ;
    }

    /**
     * 订单列表-----查订单所有
     * @param orderInfoVo
     * @return
     */
    @PostMapping("/selectAllOrder")
    public Result selectAllOrder(@RequestBody OrderInfoVo orderInfoVo){
        return orderInfoService.selectAllOrder(orderInfoVo);
    }


    /**
     * 修改订单状态
     * @param id
     * @return
     */
    @GetMapping("/updateStatus")
    public Result updateStatus(Integer id) {
        return orderInfoService.updateStatus(id);
    }

    @PostMapping("/selectOrder")
    public Result selectOrder(@RequestBody OrderInfoVo orderInfoVo) {
        return orderInfoService.selectOrder(orderInfoVo);
    }

}
